#include "junix.h"
#include <boost/variant.hpp>

using namespace std;

class A
:public boost::static_visitor<void>
{
	public:
	void operator()(int i) const
	{
		std::cout<<"int:"<<i<<std::endl;
	}

	void operator()(double d) const
	{
		std::cout<<"double:"<<d<<std::endl;
	}

	void  operator()(std::string s) const
	{
		std::cout<<"string:"<<s<<std::endl;
	}

};

int main(int argc, char **argv)
{
	boost::variant<int, double, std::string> var;
	var =1;
	var= std::string("hello,world");

	 vector< boost::variant<int,double,std::string> > vvar;
	 var = 1;
	 vvar.push_back(var);
	 var = 0.000009;
	 vvar.push_back(var);
	 var = std::string("hello,world!");
	 vvar.push_back(var);

	 boost::apply_visitor(A(),var);

	 A a;
	 for_each( vvar.begin(), vvar.end(), boost::apply_visitor(a) );
}
